<?php
include("../inc/db_connect.php");
include("../inc/functions.php");
$date0 = $_POST['date'];
$date6 = $date0 + (6*24*60*60);
$zam_s = "SELECT * FROM z WHERE stavid=1 AND patri_k='".$_POST['user_id']."' ";
$zam_q = MySQL_Query ($zam_s);
$ret = '#';
while ($zam = MySQL_Fetch_Array($zam_q)) {
    $ret .= $zam['id'];
    $nac_s = "SELECT * FROM dochadzkazamfalk WHERE planOd!='' AND planDo!='' AND date>='".$date0."' AND date<='".$date6."' AND ((type='P')OR(type='SPL')) AND zid='".$zam['id']."'";
    $nac_q = MySQL_Query ($nac_s);
    while ($nac = MySQL_Fetch_Array ($nac_q)) {
        $realOd = $nac['planOd'];
        $realDo = $nac['planDo'];

        $uloz_u = "UPDATE dochadzkazamfalk SET realOd='".$realOd."',realDo='".$realDo."' WHERE id = '".$nac['id']."'";
        $uloz_q = MySQL_Query ($uloz_u);
    }
    $ret .= '#';
}

echo $ret;
?>
